{% init file_type = "group_list" %}
{% init ungrouped_count = 0 %}

{% if file_type == "group_list" %}
    <div class="grid-row">
        <div class="grid-item">
            <img src="/static/image/folder.gif"/>
            <a class="link" href="/file/recent_edit">最近更新</a>
        </div>
        <div class="grid-item">
            <img src="/static/image/folder.gif"/>
            <a class="link" href="/file/group/public">分享文章</a>
        </div>
        <div class="grid-item">
            <img src="/static/image/folder.gif"/>
            <a class="link" href="/file/group/ungrouped">未分类</a> {{ ungrouped_count }}
        </div>
        {% for item in files %}
            <div class="grid-item">
                <img src="/static/image/folder.gif"/>
                <a class="link" href="/note/view?id={{item.id}}">{{item.name}}</a>
                {{item.size}}
            </div>
        {% end %}
    </div>
{% else %}
    <div class="x-dialog x-dialog-remote" style="height: 400px;">
        <div class="x-dialog-title">移动分组 <input type="button" class="x-dialog-close" value="关闭"/></div>
        <div class="col-md-12 scroll-y">
        {% for item in filelist %}
        <span class="tag-span-light">
            <a href="javascript:moveTo({{id}}, {{item.id}})"><span>{{item.name}}</span></a>
        </span>
        {% end %}
        </div>
    </div>

    <script type="text/javascript">
        
    function moveTo(selfId, parentId) {
        $.post("/file/group/move", 
            {id:selfId, parent_id: parentId}, 
            function (resp){
                console.log(resp);
                window.location.reload();
        });
    }

    </script>
{% end %}
